package com.gem.sms.mapper;

import com.gem.sms.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {

    @Insert("insert into zy_stu values(#{id},#{name},#{stuNo},#{password},#{birthday},#{sex},#{polity},#{brief})")
     void save(Student student); //保存学生信息

    @Delete("delete from zy_stu where stuNo=#{stuNo}")
     void delete(String stuNo); //删除学生信息

    @Select("select * from zy_stu where stuNo=#{stuNo}")
     Student getStudentByStuNo(String stuNo); //根据id获得学生对象


    @Select("select * from zy_stu where stuNo=#{stuNo} and password=#{password}")
    Student canLogin(@Param("stuNo")String stuNo, @Param("password") String password); //判断是否可以登录的方法


    @Select("select * from zy_stu where name like concat('%', #{name}, '%')")
    List<Student> selectStudentsByName(@Param("name") String name);

    @Select("select * from zy_stu ")
    List<Student> selectAllStudents();

    @Update("update zy_stu set id=#{id},name=#{name},stuNo=#{stuNo},password=#{password},birthday=#{birthday},sex=#{sex},polity=#{polity},brief=#{brief} where id=#{id}")
     void update(Student student); //修改学生信息
}
